#!/bin/bash

data=("mushroom" "retail" "T10I4D100K")
mushroom=(0.25 0.20 0.15 0.10 0.05)
retail=(0.60 0.55 0.50 0.45 0.40)
T10I4D100K=(0.005 0.004 0.003 0.002 0.001)
mushroom_ans=(5545 53663 98575 574513 3755705)
retail_ans=(0 1 1 2 2)
T10I4D100K_ans=(1073 2001 4552 13255 27532)

TIME=./common/time
DATADIR=./data

if [ -z "$1" ]
then
  echo "Missing operand"
  exit 1
fi

FREQ=./${1}/${1}

for i in ${data[@]}
do
  len=$(eval echo \${#${i}[@]})
  for ((j=0;j<len;++j))
  do
    val=$(eval echo \${${i}[${j}]})
    ans=$(eval echo \${${i}_ans[${j}]})
    echo -n "${i}.dat"$'\t'"($val)"$'\t'
    result=$(${TIME} ${FREQ} ${val} -q <${DATADIR}/${i}.dat 2>.tmp)
    time=$(cat .tmp)
    rm .tmp
    echo -n ${time}$'\t'${result}$'\t'
    if [ ${result} -eq ${ans} ]
    then
      echo Correct
    else
      echo Wrong
    fi
  done
done
